import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2023-10-30
 * Time:16:28
 * Text：计算字符串的编辑距离
 */
public class Text2 {
    public static int getDistance(String str1,String str2){

        char[] wd1=str1.toCharArray();
        char[] wd2=str2.toCharArray();
        int len1=wd1.length;
        int len2=wd2.length;

        int[][] dist=new int[len1+1][len2+1];
        for(int i=0;i<=len1;i++){
            dist[i][0]=i;
        }
        for(int i=0;i<=len2;i++){
            dist[0][i]=i;
        }
        for(int i=1;i<=len1;i++){
            for(int j=1;j<=len2;j++){
                dist[i][j]=Math.min(dist[i-1][j],dist[i][j-1])+1;
                if(wd1[i-1]==wd2[j-1])
                {
                    dist[i][j]=Math.min(dist[i][j],dist[i-1][j-1]);
                }else{
                    dist[i][j]=Math.min(dist[i][j],dist[i-1][j-1]+1);
                }
            }
        }

        return dist[len1][len2];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1=in.nextLine();
        String str2=in.nextLine();
        System.out.println(getDistance(str1,str2));
    }
}

